import { tableDataSource } from './DataFiledMockSource'


export function getDataFiledTreeData () {
  const data = []
  Object.keys(tableDataSource).forEach(key => {
    data.push({
      "label": tableDataSource[key].label,
      "value": key,
      "children": []
    })
  })
  return {
    msg: "成功",
    code: 200,
    data: data
  }
}

export function getDataFiledTableData(tableName) {
  let tableData = []
  if (tableName) {
    const dataSources = tableDataSource[tableName].source
    dataSources.forEach(item => {
      let itemArr = item.split('-')
      tableData.push({
        tableName: tableName,
        tableFiled: `${tableName}.${itemArr[0]}`,
        tableColumn: itemArr[0],
        tableColumnName: itemArr[1],
        tableRemark: itemArr[1],
      })
    })
  }
  return tableData
}